<?php

use yii\db\Migration;

class m210222_082838_addon_attend_check extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%addon_attend_check}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID'",
            'merchant_id' => "int(11) NOT NULL",
            'member_id' => "int(11) NOT NULL COMMENT '用户'",
            'classes_id' => "int(11) NULL COMMENT '班次'",
            'type' => "int(11) NOT NULL COMMENT '打卡类型'",
            'picture' => "varchar(255) NULL COMMENT '主图'",
            'covers' => "text NULL COMMENT '照片'",
            'lon' => "varchar(32) NULL COMMENT '经度'",
            'lat' => "varchar(32) NULL COMMENT '纬度'",
            'address' => "varchar(255) NULL COMMENT '地址'",
            'state' => "int(11) NOT NULL DEFAULT '0' COMMENT '打卡状态'",
            'begin_time' => "varchar(32) NULL COMMENT '开始时间'",
            'end_time' => "varchar(32) NULL COMMENT '结束时间'",
            'status' => "int(11) NOT NULL DEFAULT '1' COMMENT '状态'",
            'created_at' => "int(11) NOT NULL DEFAULT '0' COMMENT '打卡时间'",
            'updated_at' => "int(11) NOT NULL DEFAULT '0' COMMENT '修改时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考勤表'");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%addon_attend_check}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

